-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: refactor slow log format and parse slow query log to SLOW_QUERY
table.
#9290
Conversation
Assuming that a I myself will process the log file in a utility like |
There may be some conflictions between this PR and #9279 . |
@crazycs520 I have a question, do we keep old slow-log in new format maybe friendly to |
It is a good question. I would rather we don't have two formats. It feels wrong to ask a customer which slow log format they are using when we are suggesting tools to process it.
I think medium term we should offer a pt-query-digest alternative based on https://github.com/Preetam/mysqllog + using our parser for normalization :-) It is quick to build, and will save users from installing perl. |
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-Authored-By: crazycs520 <[email protected]>
Co-Authored-By: crazycs520 <[email protected]>
@zz-jason PTAL. |
sessionctx/variable/session.go
Outdated
buf.WriteString(SlowLogPrefixStr + SlowLogIndexNamesStr + SlowLogSpaceMarkStr + indexIDs + "\n") | ||
} | ||
buf.WriteString(SlowLogPrefixStr + SlowLogIsInternalStr + SlowLogSpaceMarkStr + strconv.FormatBool(s.InRestrictedSQL) + "\n") | ||
if len(sql) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what circumstances will encounter the situation of len(sql) == 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally It won't be len(sql) = 0
, but just in case, we should also print ";" when len(sql)=0
. Parser need ";" to indicate the end of slow log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
} | ||
defer func() { | ||
if err = file.Close(); err != nil { | ||
log.Error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add more information to this log.
|
||
const ( | ||
// SlowLogPrefixStr is slow log row prefix. | ||
SlowLogPrefixStr = "# " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename it to SlowLogFieldPrefixStr
or SlowLogRowPrefixStr
?
totalKeys uint64 | ||
processKeys uint64 | ||
db string | ||
indexNames string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update this field name?
What problem does this PR solve?
INFORMATION_SCHEMA.SLOW_QUERY
table, the table content is from parse slow log file.tidb_slow_query_file
seesion variable to control which slow log file to be parsed.What is changed and how it works?
New slow log format is like below, this will be friendly to some utils like
pt-query-digest
.Query
INFORMATION_SCHEMA.SLOW_QUERY
table.Check List
Tests
Code changes
Side effects
Related changes